package myapps.ttclient.activity;

import myapps.ttclient.GlobalVariables;
import myapps.ttclient.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import myapps.ttclient.activity.FileExplorerActivity;
import myapps.ttclient.activity.ppt.PPTControllingScreenActvity;
import myapps.ttclient.activity.ppt.PPTSlideShowScreenActivity;

public class MainActionsActivity extends Activity {
	
	private Button btnPPTControllingScreen;
	private Button btnFileExplorer;
	private Button btnMouseController;
	private Button btnSlideShowScreen;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.mainactions);
		
		btnPPTControllingScreen = (Button) findViewById(R.id.btnPPTControllingScreen);
		btnPPTControllingScreen.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				MainActionsActivity.this.startActivity(
						new Intent(v.getContext(), PPTControllingScreenActvity.class));
			}
		});
		
		btnFileExplorer = (Button) findViewById(R.id.btnFileExplorer);
		btnFileExplorer.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				MainActionsActivity.this.startActivity(
						new Intent(v.getContext(), FileExplorerActivity.class));
			}
		});
		
		btnMouseController = (Button) findViewById(R.id.btnMouseController);
		btnMouseController.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				MainActionsActivity.this.startActivity(
						new Intent(v.getContext(), MouseControllerActivity.class));
			}
		});
		
		btnSlideShowScreen = (Button) findViewById(R.id.btnSlideShowScreen);
		btnSlideShowScreen.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				MainActionsActivity.this.startActivity(
						new Intent(v.getContext(), PPTSlideShowScreenActivity.class));
			}
		});
		
		updateState();
	}
	
	
	public void updateState()
	{
		if( GlobalVariables.getCurrentAuthority() == GlobalVariables.AUTHORITY_ADMIN) {
			btnPPTControllingScreen.setEnabled(true);
			btnFileExplorer.setEnabled(true);
			btnMouseController.setEnabled(true);
			btnSlideShowScreen.setEnabled(true);
			
		} else if( GlobalVariables.getCurrentAuthority() == GlobalVariables.AUTHORITY_MEMBER) {
			btnPPTControllingScreen.setEnabled(false);
			btnFileExplorer.setEnabled(false);
			btnMouseController.setEnabled(false);
			btnSlideShowScreen.setEnabled(true);
			
		} else if( GlobalVariables.getCurrentAuthority() == GlobalVariables.AUTHORITY_GUEST) {
			btnPPTControllingScreen.setEnabled(false);
			btnFileExplorer.setEnabled(false);
			btnMouseController.setEnabled(false);
			btnSlideShowScreen.setEnabled(false);
			
		} else if( GlobalVariables.getCurrentAuthority() == GlobalVariables.AUTHORITY_KEY_MEMBER) {
			btnPPTControllingScreen.setEnabled(true);
			btnFileExplorer.setEnabled(true);
			btnMouseController.setEnabled(true);
			btnSlideShowScreen.setEnabled(false);
			
		}
		
	}

}
